#include "register_dialog.h"
#include "ui_register_dialog.h"
#include<QMessageBox>
register_Dialog::register_Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::register_Dialog)
{
    ui->setupUi(this);
    ui->lineEdit_password->setEchoMode(QLineEdit::Password);
    ui->lineEdit_password_2->setEchoMode(QLineEdit::Password);
}

register_Dialog::~register_Dialog()
{
    delete ui;
}

QStringList register_Dialog::getAccount()
{
    QStringList ret;
    ret.append(ui->lineEdit_login->text());
    ret.append(ui->lineEdit_password->text());
    return ret;
}

void register_Dialog::on_checkBox_clicked(bool checked)
{
    if(checked == true)
    {
        ui->lineEdit_password->setEchoMode(QLineEdit::Normal);
        ui->lineEdit_password_2->setEchoMode(QLineEdit::Normal);
    }
    else
    {
        ui->lineEdit_password->setEchoMode(QLineEdit::Password);
        ui->lineEdit_password_2->setEchoMode(QLineEdit::Password);
    }
}

void register_Dialog::on_pushButton_canle_clicked()
{
    this->close();
}

void register_Dialog::on_pushButton_ok_clicked()
{
    QString account = ui->lineEdit_login->text();
    QString password1 = ui->lineEdit_password->text();
    QString password2 = ui->lineEdit_password_2->text();
    if(account != "" && password1 != "" && password1 == password2)
    {
        this->accept();
        this->close();
    }
    else
    {
        QMessageBox message;
        message.setText("两次密码输入不同请检查!");
        message.exec();
    }
}
